1. Field of the Invention
The present invention relates to a transactional store system, and more particularly, to a method and apparatus for implementing a transactional store system based on using a helper thread.
2. Description of Related Art
The transaction is a concept that is widely used in the computer field. Generally, a transaction means that a plurality of instructions is executed in an atomic manner such that there is no other interposed operation during the execution. For instance, if a transaction accesses data at a memory address, the data in the address is not modified by operations other than that transaction until the transaction terminates.
The transaction can be implemented at a hardware level, for example, using processor architecture. The hardware component that supports the transaction in an architecture level is referred to as a hardware transactional memory (HTM) system. The transactional memory (TM) that is implemented by utilizing only software is referred to as software transactional memory (STM). TM described below refers to the complete transactional memory system. By employing a transactional memory system, a programmer does not need to use a lock when writing parallel programs. Thus, it is possible to improve the productive efficiency of the software.
All of the data that is accessed by a transaction, speculative data, will be temporary stored in a transactional buffer, but not be written into memory. If two transactions access the same address and at least one of them modifies data on the address, then one of the two transactions has to be rolled back and is re-executed, but the other one resumes. Such a case is referred to as a conflict. If there is no conflict, the data that is stored temporarily while the transaction terminates will be written into memory. Such an operation is referred as commit.
When the transaction accesses data, the current implementation of TM is to add a barrier before each transactional load/store instruction that requires it to access data by a compiler. The function of the barrier is to detect whether there is conflict by checking a lock table which records the permission for each memory block to be accessed by the transaction. Using the barrier function implies that the source code of the transaction is required to be re-compiled to add the barriers during compilation.
However, a programmer cannot write code to call the library functions since the function library provided by a third party does not usually contain source code. Many functions in the library are safe with respect to a transaction. Examples of this are “strcmp,” compare two strings, in the C language library, and “sqrt,” square root, in the C math library. Those functions cannot be called even if those functions do not contain any un-recoverable operations. Thus, not allowing those functions to be called during the execution of transactions significantly impairs productivity.